package operate;
import book.Book;
import book.BookList;
import user.User;
import java.util.Scanner;

public class Find implements IOperate{
    /**
     * 功能：搜索书籍
     * 让管理员/用户输入他要搜索的书名
     * 判断有无此书
     * 有：展示书籍信息
     * 无：打印
     * 参数：无
     * 返回类型：void
     */
    @Override
    public void operate(User user, BookList bookList) {
        System.out.println("请输入你要查找的书籍：");
        Scanner scanner = new Scanner(System.in);
        String bookName = scanner.nextLine();
        for (int i = 0; i < bookList.bookLists.size(); i++) {
            Book book = bookList.bookLists.get(i);
            if(bookName.equals(book.getName()))
            {
                System.out.println("------------------------------------查找结果------------------------------------");
                System.out.println(bookList.bookLists.get(i).toString());
                System.out.println();
                return;
            }
        }
            System.out.println("书籍 "+bookName+" 不在目录中");
        }
    }
